/**
 * Copyright (c) 2017-2024 Nop Platform. All rights reserved.
 * Author: canonical_entropy@163.com
 * Blog:   https://www.zhihu.com/people/canonical-entropy
 * Gitee:  https://gitee.com/canonical-entropy/nop-entropy
 * Github: https://github.com/entropy-cloud/nop-entropy
 */
package com.gitee.wsl.func.select

import com.gitee.wsl.func.select.collector.SelectAllCollector
import com.gitee.wsl.func.select.collector.SelectOneCollector

interface ISelector<E, C, T> {
    fun select(source: E, context: C): T? {
        val collector = SelectOneCollector<T>()
        select(source, context, collector)
        return collector.element
    }

    fun selectAll(source: E, context: C): List<T> {
        val collector = SelectAllCollector<T>()
        select(source, context, collector)
        return collector.elements
    }

    fun select(source: E, context: C, collector: ISelectionCollector<T>): SelectResult
}